.class public Lcom/felhr/usbserial/CH34xSerialDevice;
.super Lcom/felhr/usbserial/UsbSerialDevice;
.source "CH34xSerialDevice.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;
    }
.end annotation


# static fields
.field private static final CLASS_ID:Ljava/lang/String; = "CH34xSerialDevice"


# instance fields
.field private ctsCallback:Lcom/felhr/usbserial/UsbSerialInterface$UsbCTSCallback;

.field private ctsState:Z

.field private dsrCallback:Lcom/felhr/usbserial/UsbSerialInterface$UsbDSRCallback;

.field private dsrState:Z

.field private dtr:Z

.field private dtrDsrEnabled:Z

.field private flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

.field private inEndpoint:Landroid/hardware/usb/UsbEndpoint;

.field private mInterface:Landroid/hardware/usb/UsbInterface;

.field private outEndpoint:Landroid/hardware/usb/UsbEndpoint;

.field private requestIN:Landroid/hardware/usb/UsbRequest;

.field private rts:Z

.field private rtsCtsEnabled:Z


# direct methods
.method public constructor <init>(Landroid/hardware/usb/UsbDevice;Landroid/hardware/usb/UsbDeviceConnection;I)V
    .locals 0

    .line 106
    invoke-direct {p0, p1, p2}, Lcom/felhr/usbserial/UsbSerialDevice;-><init>(Landroid/hardware/usb/UsbDevice;Landroid/hardware/usb/UsbDeviceConnection;)V

    const/4 p2, 0x0

    .line 93
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtr:Z

    .line 94
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rts:Z

    .line 95
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->ctsState:Z

    .line 96
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dsrState:Z

    .line 107
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rtsCtsEnabled:Z

    .line 108
    iput-boolean p2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtrDsrEnabled:Z

    if-ltz p3, :cond_0

    move p2, p3

    .line 109
    :cond_0
    invoke-virtual {p1, p2}, Landroid/hardware/usb/UsbDevice;->getInterface(I)Landroid/hardware/usb/UsbInterface;

    move-result-object p1

    iput-object p1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->mInterface:Landroid/hardware/usb/UsbInterface;

    return-void
.end method

.method static synthetic access$000(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    iget-boolean p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rtsCtsEnabled:Z

    return p0
.end method

.method static synthetic access$100(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    iget-boolean p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->ctsState:Z

    return p0
.end method

.method static synthetic access$102(Lcom/felhr/usbserial/CH34xSerialDevice;Z)Z
    .locals 0

    .line 19
    iput-boolean p1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->ctsState:Z

    return p1
.end method

.method static synthetic access$200(Lcom/felhr/usbserial/CH34xSerialDevice;)Lcom/felhr/usbserial/UsbSerialInterface$UsbCTSCallback;
    .locals 0

    .line 19
    iget-object p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->ctsCallback:Lcom/felhr/usbserial/UsbSerialInterface$UsbCTSCallback;

    return-object p0
.end method

.method static synthetic access$300(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    iget-boolean p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtrDsrEnabled:Z

    return p0
.end method

.method static synthetic access$400(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    iget-boolean p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dsrState:Z

    return p0
.end method

.method static synthetic access$402(Lcom/felhr/usbserial/CH34xSerialDevice;Z)Z
    .locals 0

    .line 19
    iput-boolean p1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dsrState:Z

    return p1
.end method

.method static synthetic access$500(Lcom/felhr/usbserial/CH34xSerialDevice;)Lcom/felhr/usbserial/UsbSerialInterface$UsbDSRCallback;
    .locals 0

    .line 19
    iget-object p0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dsrCallback:Lcom/felhr/usbserial/UsbSerialInterface$UsbDSRCallback;

    return-object p0
.end method

.method static synthetic access$600(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkCTS()Z

    move-result p0

    return p0
.end method

.method static synthetic access$700(Lcom/felhr/usbserial/CH34xSerialDevice;)Z
    .locals 0

    .line 19
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkDSR()Z

    move-result p0

    return p0
.end method

.method private checkCTS()Z
    .locals 5

    const/4 v0, 0x2

    .line 507
    new-array v1, v0, [B

    const/4 v2, 0x0

    const/16 v3, 0x95

    const/16 v4, 0x706

    .line 508
    invoke-direct {p0, v3, v4, v2, v1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandIn(III[B)I

    move-result v3

    if-eq v3, v0, :cond_0

    .line 512
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Expected 2 bytes, but get "

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    .line 516
    :cond_0
    aget-byte v0, v1, v2

    const/4 v1, 0x1

    and-int/2addr v0, v1

    if-nez v0, :cond_1

    return v1

    :cond_1
    return v2
.end method

.method private checkDSR()Z
    .locals 5

    const/4 v0, 0x2

    .line 527
    new-array v1, v0, [B

    const/4 v2, 0x0

    const/16 v3, 0x95

    const/16 v4, 0x706

    .line 528
    invoke-direct {p0, v3, v4, v2, v1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandIn(III[B)I

    move-result v3

    if-eq v3, v0, :cond_0

    .line 532
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Expected 2 bytes, but get "

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    .line 536
    :cond_0
    aget-byte v1, v1, v2

    and-int/2addr v0, v1

    if-nez v0, :cond_1

    const/4 v0, 0x1

    return v0

    :cond_1
    return v2
.end method

.method private checkState(Ljava/lang/String;II[I)I
    .locals 2

    .line 492
    array-length v0, p4

    new-array v0, v0, [B

    const/4 v1, 0x0

    .line 493
    invoke-direct {p0, p2, p3, v1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandIn(III[B)I

    move-result p2

    .line 495
    array-length p3, p4

    if-eq p2, p3, :cond_0

    .line 497
    sget-object p3, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Expected "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    array-length p4, p4

    invoke-virtual {v0, p4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string p4, " bytes, but get "

    invoke-virtual {v0, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string p2, " ["

    invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string p1, "]"

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-static {p3, p1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const/4 p1, -0x1

    return p1

    :cond_0
    return v1
.end method

.method private createFlowControlThread()V
    .locals 1

    .line 581
    new-instance v0, Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    invoke-direct {v0, p0}, Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;-><init>(Lcom/felhr/usbserial/CH34xSerialDevice;)V

    iput-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    return-void
.end method

.method private init()I
    .locals 10

    const/4 v0, 0x0

    const/16 v1, 0xa1

    const v2, 0xc29c

    const v3, 0xb2b9

    .line 400
    invoke-direct {p0, v1, v2, v3, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v1

    const/4 v2, -0x1

    if-gez v1, :cond_0

    .line 402
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #1"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_0
    const/16 v1, 0xdf

    const/16 v3, 0xa4

    const/4 v4, 0x0

    .line 406
    invoke-direct {p0, v3, v1, v4, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v1

    if-gez v1, :cond_1

    .line 408
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #2"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_1
    const/16 v1, 0x9f

    .line 412
    invoke-direct {p0, v3, v1, v4, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v1

    if-gez v1, :cond_2

    .line 414
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #3"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_2
    const/4 v1, 0x2

    .line 418
    new-array v3, v1, [I

    fill-array-data v3, :array_0

    const/16 v5, 0x706

    const/16 v6, 0x95

    const-string v7, "init #4"

    invoke-direct {p0, v7, v6, v5, v3}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkState(Ljava/lang/String;II[I)I

    move-result v3

    if-ne v3, v2, :cond_3

    return v2

    :cond_3
    const/16 v3, 0x2727

    const/16 v7, 0x9a

    .line 421
    invoke-direct {p0, v7, v3, v4, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v8

    if-gez v8, :cond_4

    .line 423
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #5"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_4
    const/16 v8, 0x1312

    const v9, 0xb282

    .line 427
    invoke-direct {p0, v7, v8, v9, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v8

    if-gez v8, :cond_5

    .line 429
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #6"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_5
    const/16 v8, 0xf2c

    const/16 v9, 0x8

    .line 433
    invoke-direct {p0, v7, v8, v9, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v8

    if-gez v8, :cond_6

    .line 435
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #7"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_6
    const/16 v8, 0x2518

    const/16 v9, 0xc3

    .line 439
    invoke-direct {p0, v7, v8, v9, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v8

    if-gez v8, :cond_7

    .line 441
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #8"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    .line 445
    :cond_7
    new-array v1, v1, [I

    fill-array-data v1, :array_1

    const-string v8, "init #9"

    invoke-direct {p0, v8, v6, v5, v1}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkState(Ljava/lang/String;II[I)I

    move-result v1

    if-ne v1, v2, :cond_8

    return v2

    .line 448
    :cond_8
    invoke-direct {p0, v7, v3, v4, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result v0

    if-gez v0, :cond_9

    .line 450
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v1, "init failed! #10"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v2

    :cond_9
    return v4

    :array_0
    .array-data 4
        0x9f
        0xee
    .end array-data

    :array_1
    .array-data 4
        0x9f
        0xee
    .end array-data
.end method

.method private openCH34X()Z
    .locals 8

    .line 366
    iget-object v0, p0, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    iget-object v1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->mInterface:Landroid/hardware/usb/UsbInterface;

    const/4 v2, 0x1

    invoke-virtual {v0, v1, v2}, Landroid/hardware/usb/UsbDeviceConnection;->claimInterface(Landroid/hardware/usb/UsbInterface;Z)Z

    move-result v0

    const/4 v1, 0x0

    if-eqz v0, :cond_4

    .line 368
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v3, "Interface succesfully claimed"

    invoke-static {v0, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 376
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->mInterface:Landroid/hardware/usb/UsbInterface;

    invoke-virtual {v0}, Landroid/hardware/usb/UsbInterface;->getEndpointCount()I

    move-result v0

    const/4 v3, 0x0

    :goto_0
    add-int/lit8 v4, v0, -0x1

    if-gt v3, v4, :cond_2

    .line 379
    iget-object v4, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->mInterface:Landroid/hardware/usb/UsbInterface;

    invoke-virtual {v4, v3}, Landroid/hardware/usb/UsbInterface;->getEndpoint(I)Landroid/hardware/usb/UsbEndpoint;

    move-result-object v4

    .line 380
    invoke-virtual {v4}, Landroid/hardware/usb/UsbEndpoint;->getType()I

    move-result v5

    const/4 v6, 0x2

    if-ne v5, v6, :cond_0

    .line 381
    invoke-virtual {v4}, Landroid/hardware/usb/UsbEndpoint;->getDirection()I

    move-result v5

    const/16 v7, 0x80

    if-ne v5, v7, :cond_0

    .line 383
    iput-object v4, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->inEndpoint:Landroid/hardware/usb/UsbEndpoint;

    goto :goto_1

    .line 384
    :cond_0
    invoke-virtual {v4}, Landroid/hardware/usb/UsbEndpoint;->getType()I

    move-result v5

    if-ne v5, v6, :cond_1

    .line 385
    invoke-virtual {v4}, Landroid/hardware/usb/UsbEndpoint;->getDirection()I

    move-result v5

    if-nez v5, :cond_1

    .line 387
    iput-object v4, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->outEndpoint:Landroid/hardware/usb/UsbEndpoint;

    :cond_1
    :goto_1
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 391
    :cond_2
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->init()I

    move-result v0

    if-nez v0, :cond_3

    const/4 v1, 0x1

    :cond_3
    return v1

    .line 371
    :cond_4
    sget-object v0, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    const-string v2, "Interface could not be claimed"

    invoke-static {v0, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return v1
.end method

.method private setBaudRate(II)I
    .locals 5

    const/4 v0, 0x0

    const/16 v1, 0x9a

    const/16 v2, 0x1312

    .line 459
    invoke-direct {p0, v1, v2, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    const/4 v2, -0x1

    if-gez p1, :cond_0

    return v2

    :cond_0
    const/16 p1, 0xf2c

    .line 461
    invoke-direct {p0, v1, p1, p2, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    if-gez p1, :cond_1

    return v2

    :cond_1
    const/16 p1, 0x95

    const/16 p2, 0x706

    const/4 v3, 0x2

    .line 463
    new-array v3, v3, [I

    fill-array-data v3, :array_0

    const-string v4, "set_baud_rate"

    invoke-direct {p0, v4, p1, p2, v3}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkState(Ljava/lang/String;II[I)I

    move-result p1

    if-ne p1, v2, :cond_2

    return v2

    :cond_2
    const/16 p1, 0x2727

    const/4 p2, 0x0

    .line 465
    invoke-direct {p0, v1, p1, p2, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    if-gez p1, :cond_3

    return v2

    :cond_3
    return p2

    :array_0
    .array-data 4
        0x9f
        0xee
    .end array-data
.end method

.method private setCh340xFlow(I)I
    .locals 4

    const/4 v0, 0x2

    .line 483
    new-array v0, v0, [I

    fill-array-data v0, :array_0

    const-string v1, "set_flow_control"

    const/16 v2, 0x95

    const/16 v3, 0x706

    invoke-direct {p0, v1, v2, v3, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkState(Ljava/lang/String;II[I)I

    move-result v0

    const/4 v1, -0x1

    if-ne v0, v1, :cond_0

    return v1

    :cond_0
    const/16 v0, 0x9a

    const/16 v2, 0x2727

    const/4 v3, 0x0

    .line 485
    invoke-direct {p0, v0, v2, p1, v3}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    if-ne p1, v1, :cond_1

    return v1

    :cond_1
    const/4 p1, 0x0

    return p1

    :array_0
    .array-data 4
        0x9f
        0xee
    .end array-data
.end method

.method private setCh340xParity(I)I
    .locals 6

    const/4 v0, 0x0

    const/16 v1, 0x9a

    const/16 v2, 0x2518

    .line 472
    invoke-direct {p0, v1, v2, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    const/4 v2, -0x1

    if-gez p1, :cond_0

    return v2

    :cond_0
    const/16 p1, 0x95

    const/16 v3, 0x706

    const/4 v4, 0x2

    .line 474
    new-array v4, v4, [I

    fill-array-data v4, :array_0

    const-string v5, "set_parity"

    invoke-direct {p0, v5, p1, v3, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkState(Ljava/lang/String;II[I)I

    move-result p1

    if-ne p1, v2, :cond_1

    return v2

    :cond_1
    const/16 p1, 0x2727

    const/4 v3, 0x0

    .line 476
    invoke-direct {p0, v1, p1, v3, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setControlCommandOut(III[B)I

    move-result p1

    if-gez p1, :cond_2

    return v2

    :cond_2
    return v3

    nop

    :array_0
    .array-data 4
        0x9f
        0xee
    .end array-data
.end method

.method private setControlCommandIn(III[B)I
    .locals 9

    if-eqz p4, :cond_0

    .line 572
    array-length v0, p4

    move v7, v0

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    const/4 v7, 0x0

    .line 574
    :goto_0
    iget-object v1, p0, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    const/16 v2, 0xc0

    const/16 v8, 0x1388

    move v3, p1

    move v4, p2

    move v5, p3

    move-object v6, p4

    invoke-virtual/range {v1 .. v8}, Landroid/hardware/usb/UsbDeviceConnection;->controlTransfer(IIII[BII)I

    move-result p1

    .line 575
    sget-object p2, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    new-instance p3, Ljava/lang/StringBuilder;

    invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V

    const-string p4, "Control Transfer Response: "

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p4

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p3

    invoke-static {p2, p3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return p1
.end method

.method private setControlCommandOut(III[B)I
    .locals 9

    if-eqz p4, :cond_0

    .line 560
    array-length v0, p4

    move v7, v0

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    const/4 v7, 0x0

    .line 562
    :goto_0
    iget-object v1, p0, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    const/16 v2, 0x40

    const/16 v8, 0x1388

    move v3, p1

    move v4, p2

    move v5, p3

    move-object v6, p4

    invoke-virtual/range {v1 .. v8}, Landroid/hardware/usb/UsbDeviceConnection;->controlTransfer(IIII[BII)I

    move-result p1

    .line 563
    sget-object p2, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    new-instance p3, Ljava/lang/StringBuilder;

    invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V

    const-string p4, "Control Transfer Response: "

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object p4

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p3

    invoke-static {p2, p3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    return p1
.end method

.method private startFlowControlThread()V
    .locals 1

    .line 586
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    invoke-virtual {v0}, Ljava/lang/Thread;->isAlive()Z

    move-result v0

    if-nez v0, :cond_0

    .line 587
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    :cond_0
    return-void
.end method

.method private stopFlowControlThread()V
    .locals 1

    .line 592
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    if-eqz v0, :cond_0

    .line 594
    invoke-virtual {v0}, Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;->stopThread()V

    const/4 v0, 0x0

    .line 595
    iput-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->flowControlThread:Lcom/felhr/usbserial/CH34xSerialDevice$FlowControlThread;

    :cond_0
    return-void
.end method


# virtual methods
.method public close()V
    .locals 2

    .line 144
    invoke-virtual {p0}, Lcom/felhr/usbserial/UsbSerialDevice;->killWorkingThread()V

    .line 145
    invoke-virtual {p0}, Lcom/felhr/usbserial/UsbSerialDevice;->killWriteThread()V

    .line 146
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->stopFlowControlThread()V

    .line 147
    iget-object v0, p0, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    iget-object v1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->mInterface:Landroid/hardware/usb/UsbInterface;

    invoke-virtual {v0, v1}, Landroid/hardware/usb/UsbDeviceConnection;->releaseInterface(Landroid/hardware/usb/UsbInterface;)Z

    return-void
.end method

.method public getBreak(Lcom/felhr/usbserial/UsbSerialInterface$UsbBreakCallback;)V
    .locals 0

    return-void
.end method

.method public open()Z
    .locals 3

    .line 115
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->openCH34X()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 119
    new-instance v0, Landroid/hardware/usb/UsbRequest;

    invoke-direct {v0}, Landroid/hardware/usb/UsbRequest;-><init>()V

    iput-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->requestIN:Landroid/hardware/usb/UsbRequest;

    .line 120
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->requestIN:Landroid/hardware/usb/UsbRequest;

    iget-object v1, p0, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    iget-object v2, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->inEndpoint:Landroid/hardware/usb/UsbEndpoint;

    invoke-virtual {v0, v1, v2}, Landroid/hardware/usb/UsbRequest;->initialize(Landroid/hardware/usb/UsbDeviceConnection;Landroid/hardware/usb/UsbEndpoint;)Z

    .line 123
    invoke-virtual {p0}, Lcom/felhr/usbserial/UsbSerialDevice;->restartWorkingThread()V

    .line 124
    invoke-virtual {p0}, Lcom/felhr/usbserial/UsbSerialDevice;->restartWriteThread()V

    .line 127
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->createFlowControlThread()V

    .line 130
    iget-object v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->requestIN:Landroid/hardware/usb/UsbRequest;

    iget-object v1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->outEndpoint:Landroid/hardware/usb/UsbEndpoint;

    invoke-virtual {p0, v0, v1}, Lcom/felhr/usbserial/UsbSerialDevice;->setThreadsParams(Landroid/hardware/usb/UsbRequest;Landroid/hardware/usb/UsbEndpoint;)V

    const/4 v0, 0x1

    .line 132
    iput-boolean v0, p0, Lcom/felhr/usbserial/UsbSerialDevice;->asyncMode:Z

    return v0

    :cond_0
    const/4 v0, 0x0

    return v0
.end method

.method public setBaudRate(I)V
    .locals 5

    const/16 v0, 0x12c

    const-string v1, "SetBaudRate failed!"

    const/4 v2, -0x1

    if-gt p1, v0, :cond_0

    const p1, 0xd980

    const/16 v0, 0xeb

    .line 179
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 181
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_0
    const/16 v3, 0x258

    if-le p1, v0, :cond_1

    if-gt p1, v3, :cond_1

    const/16 p1, 0x6481

    const/16 v0, 0x76

    .line 184
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 186
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_1
    const/16 v0, 0x4b0

    if-le p1, v3, :cond_2

    if-gt p1, v0, :cond_2

    const p1, 0xb281

    const/16 v0, 0x3b

    .line 190
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 192
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_2
    const/16 v3, 0x960

    if-le p1, v0, :cond_3

    if-gt p1, v3, :cond_3

    const p1, 0xd981

    const/16 v0, 0x1e

    .line 195
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 197
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_3
    const/16 v0, 0x12c0

    if-le p1, v3, :cond_4

    if-gt p1, v0, :cond_4

    const/16 p1, 0x6482

    const/16 v0, 0xf

    .line 200
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 202
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_4
    const/16 v3, 0x2580

    if-le p1, v0, :cond_5

    if-gt p1, v3, :cond_5

    const p1, 0xb282

    const/16 v0, 0x8

    .line 205
    invoke-direct {p0, p1, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 207
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_5
    const/16 v0, 0x4b00

    const/4 v4, 0x7

    if-le p1, v3, :cond_6

    if-gt p1, v0, :cond_6

    const p1, 0xd982

    .line 210
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 212
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_6
    const v3, 0x9600

    if-le p1, v0, :cond_7

    if-gt p1, v3, :cond_7

    const/16 p1, 0x6483

    .line 215
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 217
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_0

    :cond_7
    const v0, 0xe100

    if-le p1, v3, :cond_8

    if-gt p1, v0, :cond_8

    const p1, 0x9883

    .line 220
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 222
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    :cond_8
    const v3, 0x1c200

    if-le p1, v0, :cond_9

    if-gt p1, v3, :cond_9

    const p1, 0xcc83

    .line 225
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 227
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    :cond_9
    const v0, 0x38400

    if-le p1, v3, :cond_a

    if-gt p1, v0, :cond_a

    const p1, 0xe683

    .line 230
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 232
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    :cond_a
    const v3, 0x70800

    if-le p1, v0, :cond_b

    if-gt p1, v3, :cond_b

    const p1, 0xf383

    .line 235
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 237
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    :cond_b
    if-le p1, v3, :cond_c

    const v0, 0xe1000

    if-gt p1, v0, :cond_c

    const p1, 0xf387

    .line 240
    invoke-direct {p0, p1, v4}, Lcom/felhr/usbserial/CH34xSerialDevice;->setBaudRate(II)I

    move-result p1

    if-ne p1, v2, :cond_c

    .line 242
    sget-object p1, Lcom/felhr/usbserial/CH34xSerialDevice;->CLASS_ID:Ljava/lang/String;

    invoke-static {p1, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    :cond_c
    :goto_0
    return-void
.end method

.method public setDataBits(I)V
    .locals 0

    return-void
.end method

.method public setFlowControl(I)V
    .locals 3

    const/4 v0, 0x0

    if-eqz p1, :cond_2

    const/4 v1, 0x1

    if-eq p1, v1, :cond_1

    const/4 v2, 0x2

    if-eq p1, v2, :cond_0

    goto :goto_0

    .line 303
    :cond_0
    iput-boolean v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rtsCtsEnabled:Z

    .line 304
    iput-boolean v1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtrDsrEnabled:Z

    const/16 p1, 0x202

    .line 305
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xFlow(I)I

    .line 306
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkDSR()Z

    move-result p1

    iput-boolean p1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dsrState:Z

    .line 307
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->startFlowControlThread()V

    goto :goto_0

    .line 296
    :cond_1
    iput-boolean v1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rtsCtsEnabled:Z

    .line 297
    iput-boolean v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtrDsrEnabled:Z

    const/16 p1, 0x101

    .line 298
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xFlow(I)I

    .line 299
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->checkCTS()Z

    move-result p1

    iput-boolean p1, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->ctsState:Z

    .line 300
    invoke-direct {p0}, Lcom/felhr/usbserial/CH34xSerialDevice;->startFlowControlThread()V

    goto :goto_0

    .line 291
    :cond_2
    iput-boolean v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->rtsCtsEnabled:Z

    .line 292
    iput-boolean v0, p0, Lcom/felhr/usbserial/CH34xSerialDevice;->dtrDsrEnabled:Z

    .line 293
    invoke-direct {p0, v0}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xFlow(I)I

    :goto_0
    return-void
.end method

.method public setParity(I)V
    .locals 1

    if-eqz p1, :cond_4

    const/4 v0, 0x1

    if-eq p1, v0, :cond_3

    const/4 v0, 0x2

    if-eq p1, v0, :cond_2

    const/4 v0, 0x3

    if-eq p1, v0, :cond_1

    const/4 v0, 0x4

    if-eq p1, v0, :cond_0

    goto :goto_0

    :cond_0
    const/16 p1, 0xfb

    .line 278
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xParity(I)I

    goto :goto_0

    :cond_1
    const/16 p1, 0xeb

    .line 275
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xParity(I)I

    goto :goto_0

    :cond_2
    const/16 p1, 0xdb

    .line 272
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xParity(I)I

    goto :goto_0

    :cond_3
    const/16 p1, 0xcb

    .line 269
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xParity(I)I

    goto :goto_0

    :cond_4
    const/16 p1, 0xc3

    .line 266
    invoke-direct {p0, p1}, Lcom/felhr/usbserial/CH34xSerialDevice;->setCh340xParity(I)I

    :goto_0
    return-void
.end method

.method public setStopBits(I)V
    .locals 0

    return-void
.end method
